class Solution {
public:
    int findMin(vector<int>& nums)
    {
        int n = nums.size();
        int lhs = 0, rhs = n - 1;
        int mid = lhs + (rhs - lhs) / 2;

        while (lhs < rhs)
        {
            if (nums[mid] > nums[n - 1]) lhs = mid + 1;
            else rhs = mid;

            mid = lhs + (rhs - lhs) / 2;
        }

        return nums[lhs];
    }
};



class Solution {
public:
    int findMin(vector<int>& nums)
    {
        int n = nums.size();
        int lhs = 0, rhs = n - 1;
        int mid = lhs + (rhs - lhs) / 2;

        while (lhs < rhs)
        {
            if (nums[mid] >= nums[0]) lhs = mid + 1;
            else rhs = mid;

            mid = lhs + (rhs - lhs) / 2;
        }

        if (rhs == n - 1 && rhs > 0 && nums[rhs] > nums[rhs - 1]) return nums[0];
        else return nums[lhs];
    }
};